﻿using System.Collections.Generic;
using HMIS.FrameWork.DomainBase;
using HMIS.Infrastructure.Core.Authority;
using HMIS.Infrastructure.Core.Authority.Services;
using HMIS.Infrastructure.Core.Repositories;

namespace HMIS.Infrastructure.Facade.Authority.Impl
{
    public class RoleFacadeImpl : IRoleFacade
    {
        private readonly IRoleRepository RoleRepository;
        private readonly IRoleService RoleService;
        public RoleFacadeImpl(IRoleRepository RoleRepository, IRoleService RoleService)
        {
            this.RoleRepository = RoleRepository;
            this.RoleService = RoleService;
        }

        #region IRoleFacade 成员

		public IList<Role> GetPlist(int start, int limit, string sort, string dir, List<DataFilter> filters, out long total)
		{
			return RoleRepository.GetPlist(start, limit, sort, dir, filters, out total);
		}

        public IList<Role> GetPlistAll(int start, int limit, string sort, string dir, List<DataFilter> filters, out long total)
        {
            return RoleRepository.GetPlistAll(start, limit, sort, dir, filters, out total);
        }

        public bool IsFieldExist(string fieldName, string fieldValue, string id)
        {
            return RoleRepository.IsFieldExist(fieldName, fieldValue, id);
        }

        public void SaveOrUpdate(Role entity)
        {
            this.RoleRepository.SaveOrUpdate(entity);
        }

        public void Delete(string id)
        {
            RoleRepository.Delete(id);
        }

        public IList<Role> QueryPlist(string query, int start, int limit, out long total)
        {
            return RoleRepository.QueryPlist(query, start, limit, out total);
        }

        public Role Get(string id)
        {
            return RoleRepository.Get(id);
        }

        public Role Load(string id)
        {
            return RoleRepository.Load(id);
        }

        public Role GetByIdWithMenuAndPermissions(string id)
        {
            return RoleRepository.GetByIdWithMenuAndPermissions(id);
        }

        public void SaveRole(Role role, string inheritedRoleId)
        {
            RoleService.SaveRole(role, inheritedRoleId);
        }
        #endregion
    }
}
